import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "../components/Home";
import Index from "../components/Index";

/*导入全局样式表*/
import '../assets/css/global.css';
/*引入图标*/
import '../assets/iconfont/iconfont.css'

import Back from "../views/backlog/Back";
import Mean from "../views/backlog/Mean";
import Permission from "../views/management/Permission";
import Role from "../views/management/Role";
import System from "../views/management/System";
import User from "../views/management/User";
import Way from "../views/line/Way";
import BugBar from "../views/defect/BugBar";
import DefectType from "../views/defect/DefectType";
import DefectsInTheQuery from "../views/lnspection/DefectsInTheQuery";
import PatrolInspectionIsCarriedOut from "../views/lnspection/PatrolInspectionIsCarriedOut";
import PatrolTaskFormulation from "../views/lnspection/PatrolTaskFormulation";
import EliminateTaskExecution from "../views/absent/EliminateTaskExecution";
import EliminateTaskFormulation from "../views/absent/EliminateTaskFormulation";
import TheQueryForGettingRidOf from "../views/absent/TheQueryForGettingRidOf";
import EliminateRecordStatistics from "../views/information/EliminateRecordStatistics";
import StatisticsOfInspectionRecords from "../views/information/StatisticsOfInspectionRecords";
import Pinecone from "../views/foundation/Pinecone"
import Tower from "../views/foundation/Tower"
Vue.use(VueRouter)

const routes = [
    // {
    //     path: '/',
    //     name: 'Index',
    //     redirect: '/home',
    // },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login/login.vue')
    },
    {
        path: '/',
        name: 'Home',
        component: Home,
        redirect:'Back',
        children: [
            {path: '', component: Back},
            {path: 'index', component: Index},
            {path: 'back', component: Back},
            {path: 'mean', component: Mean},
            {path: 'permission', component: Permission},
            {path: 'role', component: Role},
            {path: 'system', component: System},
            {path: 'user', component: User},
            {path: 'pinecone', component: Tower},
            {path: 'way', component: Way},
            {path: 'bugBar', component: BugBar},
            {path: 'defecttype', component: DefectType},
            {path: 'defectsinthequery', component: DefectsInTheQuery},
            {path: 'patrolinspectioniscarriedout', component: PatrolInspectionIsCarriedOut},
            {path: 'patroltaskformulation', component: PatrolTaskFormulation},
            {path: 'eliminatetaskexecution', component: EliminateTaskExecution},
            {path: 'eliminatetaskformulation', component: EliminateTaskFormulation},
            {path: 'thequeryforgettingridof', component: TheQueryForGettingRidOf},
            {path: 'eliminaterecordstatistics', component: EliminateRecordStatistics},
            {path: 'statisticsofinspectionrecords', component: StatisticsOfInspectionRecords}
        ]
    }
]



const router = new VueRouter({
    routes
})

/**
 * 登录验证
 */
router.beforeEach((to, from, next)=>{
    if (to.path === '/login') {
        return next();
    }
    //不是登录
    const loginToken = window.sessionStorage.getItem("accountToken");
    if (!loginToken) {
        return next('/login');
    }
    next();
});


export default router
